Skip to content

router: support offseting downstream provided grpc timeout#6628

Merged
snowp merged 11 commits intoenvoyproxy:masterfrom
snowp:grpc-timeout-offset
Apr 20, 2019
Merged

router: support offseting downstream provided grpc timeout#6628
snowp merged 11 commits intoenvoyproxy:masterfrom
snowp:grpc-timeout-offset

Conversation

@snowp
Copy link
Copy Markdown
Contributor

@snowp snowp commented Apr 17, 2019

This adds support for modifying the grpc-timeout provided by the
downstream by some offset. This is useful to make sure that Envoy is
able to see timeouts before the gRPC client does, as the client will
cancel the request when the deadline has been exceeded which hides the
timeout from the outlier detector.

Signed-off-by: Snow Pettersen snowp@squareup.com

Risk Level: Low, new optional feature
Testing: Added UT test cases
Docs Changes: Proto docs
Release Notes: added version note
Fixes #6566

Snow Pettersen added 4 commits April 17, 2019 15:47
This adds support for modifying the grpc-timeout provided by the
downstream by some offset. This is useful to make sure that Envoy is
able to see timeouts before the gRPC client does, as the client will
cancel the request when the deadline has been exceeded which hides the
timeout from the outlier detector.

Signed-off-by: Snow Pettersen <snowp@squareup.com>
Signed-off-by: Snow Pettersen <snowp@squareup.com>
Signed-off-by: Snow Pettersen <snowp@squareup.com>
Signed-off-by: Snow Pettersen <snowp@squareup.com>
htuch
htuch previously approved these changes Apr 17, 2019
Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You anticipated all my review feedback, so LGTM. Thanks!

@htuch htuch self-assigned this Apr 17, 2019
Signed-off-by: Snow Pettersen <snowp@squareup.com>
@snowp
Copy link
Copy Markdown
Contributor Author

snowp commented Apr 18, 2019

/retest

@repokitteh-read-only
Copy link
Copy Markdown

🔨 rebuilding ci/circleci: release (failed build)

🐱

Caused by: a #6628 (comment) was created by @snowp.

see: more, trace.

htuch
htuch previously approved these changes Apr 18, 2019
@htuch
Copy link
Copy Markdown
Member

htuch commented Apr 18, 2019

@snowp darn, looks like this needs master merge.

Signed-off-by: Snow Pettersen <snowp@squareup.com>
@snowp
Copy link
Copy Markdown
Contributor Author

snowp commented Apr 18, 2019

It's unfortunate that the release notes files makes merge conflicts so common, though I don't really know how you'd do otherwise

Snow Pettersen added 2 commits April 18, 2019 18:01
Signed-off-by: Snow Pettersen <snowp@squareup.com>
Signed-off-by: Snow Pettersen <snowp@squareup.com>
htuch
htuch previously approved these changes Apr 18, 2019
@snowp
Copy link
Copy Markdown
Contributor Author

snowp commented Apr 19, 2019

@mattklein123 Wanna give this one a quick look?

@mattklein123 mattklein123 self-assigned this Apr 19, 2019
Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with small question/comment. Thank you!

/wait

std::chrono::milliseconds grpc_timeout = Grpc::Common::getGrpcTimeout(request_headers);
if (route.grpcTimeoutOffset()) {
grpc_timeout =
std::max(std::chrono::milliseconds::zero(), (grpc_timeout - *route.grpcTimeoutOffset()));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presumably std::chrono::milliseconds is signed and this won't wrap around? Can you potentially add a comment?

Also, if we end up setting this to zero, it will effectively disable the timeout, right? Should the default in this case actually be to use the supplied timeout in the header? That seems safer? I could go either way. Whatever you choose, can you update the docs to say what happens if the value is larger than the supplied header?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accoriding to https://en.cppreference.com/w/cpp/chrono/duration the value is signed:

std::chrono::milliseconds | duration</*signed integer type of at least 45 bits*/, std::milli>

There's code further down that handles the case where the timeout ends up at zero: it changes it to the value of route.maxGrpcTimout. That said, it does seem safer to not apply the offset in that case, because it would end up increasing the timeout instead of decreasing it which is likely the intended result

Signed-off-by: Snow Pettersen <snowp@squareup.com>
Snow Pettersen added 2 commits April 19, 2019 13:35
Signed-off-by: Snow Pettersen <snowp@squareup.com>
Signed-off-by: Snow Pettersen <snowp@squareup.com>
@snowp
Copy link
Copy Markdown
Contributor Author

snowp commented Apr 19, 2019

/retest

@repokitteh-read-only
Copy link
Copy Markdown

🔨 rebuilding ci/circleci: tsan (failed build)

🐱

Caused by: a #6628 (comment) was created by @snowp.

see: more, trace.

Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks.

@snowp snowp merged commit 03ae1ef into envoyproxy:master Apr 20, 2019
mpuncel added a commit to mpuncel/envoy that referenced this pull request Apr 22, 2019
* master:
  thread: remove ThreadFactorySingleton (envoyproxy#6658)
  router: support offseting downstream provided grpc timeout (envoyproxy#6628)
  router: defer per try timeout until downstream request is done (envoyproxy#6643)
  update bazel readme for clang-format-8 on mac (envoyproxy#6660)
  Implement some TODOs in quic_endian_impl.h (envoyproxy#6644)
  docs: add aspell to mac dependencies to fix check format script (envoyproxy#6661)
  config: fix delta xDS's use of (un)subscribe fields, more explicit protocol spec (envoyproxy#6545)

Signed-off-by: Michael Puncel <mpuncel@squareup.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve grpc timeout interaction with outlier detection

3 participants